<?php
	if(isset($_REQUEST['control'])){
		include("user_verify.php");
	}
?>
<div class="action">
	<div class="icon_info"></div>
    <div class="management">
        User Information
    </div>
    <div class="new">
    	<?php if(has_permission("user_new")){?>
       		<a href="index.php?page=users/user_list&action=users/user_new">Add New</a>
        <?php } ?>
    </div>
</div>
    <div class="sms">
        <?php 
        if(isset($_REQUEST['msgStatus'])){
            echo $_REQUEST['msgStatus'];
        }else{echo @$errors;}
        ?>
    </div>	
<div id="dt_example">
    <table cellpadding="0" cellspacing="0" border="0" class="display" id="example">
        <thead>
            <tr>
                <th>Photo</th>
                <th>Group</th>
                <th>Department</th>
                <th>Full Name</th>
                <th>Login Name</th>
                <th>Gender</th>
                <th>E-mail</th>
                <th>Phone</th>
                <th>Status</th>
                <th>Address</th>
                <th>Permission</th>
                <th>Action</th>
            </tr>
        </thead>
        <tbody>
            <?php
            $sql = "SELECT u.user_id,u.gro_id,u.full_name,tbl_category.cat_name as department,u.user_login AS user_name,u.gender,u.active,u.email, u.address,u.photo,g.gro_name 
					FROM tbl_user AS u INNER JOIN tbl_group AS g ON u.gro_id=g.gro_id LEFT JOIN tbl_category ON  u.cat_id = tbl_category.cat_id ORDER BY u.user_id DESC ";
            $result = mysql_query($sql);
            while ( $row = mysql_fetch_object($result)){
            ?>
            <tr >
            	<td><img src="users/<?php $photo=$row->photo; echo $photo;  ?>" width="80" height="100"  /></td>
                <td><?php echo $row->gro_name; ?></td>
                <td><?php echo $row->department; ?></td>
                <td><?php echo $row->full_name; ?></td>
                <td><?php echo $row->user_name; ?></td>
                <td><?php echo $row->gender; ?></td>
                <td><?php echo $row->email; ?></td>
                <td><?php echo $row->phone; ?></td>
                <td>
                <?php if(has_permission("userPublish")){?>
                    <?php 
                      $icon_publish = $row->active==0 ? "publish_x.png" : "publish_y.png";
                      $publish_image = "<img width='15px' src='images/{$icon_publish}' />";														
                    ?>
                      <a href="index.php?page=user_list&action=user_list&control=publish&active=<?php echo $row->active. "&user_id=" . $row->user_id. "&user_name=" . $row->user_name;?>">
                    <?php echo $publish_image; ?></a>
                <?php } else  echo "<div class='no_per'></div>";?>
                </td>
                <td><?php echo $row->address; ?></td>
                <td>
                <?php if(has_permission("user_permission")){?>
                	<a href="index.php?page=users/user_list&action=user_permission&user_id=<?php echo $row->user_id;?>&user_name_per=<?php echo $row->user_name;?>"><img src="images/user_per.png"  /></a> 
                <?php } else  echo "<div class='no_per'></div>";?>
                </td>
                <td>
                <?php if(has_permission("userEdit")){?>
                	<a href="index.php?page=users/user_list&action=users/user_new&user_id=<?php echo $row->user_id	; ?>"><img class="fa fa-edit" src="images/edit.png" border="0" alt="Edit"></a> 
                <?php } else  echo "<div class='no_per'></div>";?>
                </td>
    
            </tr>
            <?php 
            }
            ?>  
        </tbody>
    </table>
</div>